{extend name="property/public/insidePageBase" /}
{block name="title"}绑定房间{/block}
{block name="body"}
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">关键字查询</label>
                    <div class="layui-input-inline">
                        <input type="text" name="keywords" placeholder="请输入房间名称查询" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                </div>
            </div>
        </form>
        <table class="layui-hide" id="roomList" lay-filter="roomList"></table>
        <script type="text/html" id="room_name_tpl">
            {{# if(d.status === 1) { }}
                <span class="layui-badge layui-bg-cyan">空</span>
            {{# } }}
            {{ d.full_room_name }}
        </script>
    </div>
</div>
{/block}
{block name="js"}
{__block__}
<script>
    var roomId = [];
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,form = layui.form,table = layui.table;
        var tableId = 'roomList';
        table.render({
            elem: '#'+tableId,
            id:tableId,
            url: '{:url("propertyContractRoomBound")}?property_id={$info['property_id']}',
            cols: [[
                {type: "radio", width: 50},
                {field: 'full_room_name', minWidth: 168, title: '房间名称'}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            height: 'full-80'
        });
        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {table.reload(tableId, {page: { curr: 1  }, where: data.field}, 'data'); return false; });
        table.on('radio('+tableId+')', function (obj) {
            let data = table.checkStatus(tableId).data
            roomId = []
            data.forEach((item) => {
                roomId.push(item.id)
            })
        });
    });
</script>
{/block}